<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui" template="template.xhtml">

	<ui:define name="main">
		<h:form id="formConsultaProfessor">
			<div class="header header_professor" />
			<p:commandButton value="#{msgs.menu_inclusao_professores_creche}"
					action="cadastro_professor"
					 ajax="false" />
			<p:panel id="painelConsulta" header="#{msgs.professores_cadastrados}"
				styleClass="painelConsulta">
				<p:dataTable var="professor"
					value="#{professorBean.listaProfessores}"
					emptyMessage="#{msgs.pesquisa_vazia}#{msgs.dois_pontos}">
					<p:column style="width:150px;text-align:center"
						headerText="#{msgs.nome}#{msgs.dois_pontos}"
						filterBy="#{professor.nome}" filterMatchMode="contains"
						footerText="#{msgs.contem}">
						<h:outputText value="#{professor.nome}" />
					</p:column>
					<p:column style="width:150px;text-align:center"
						headerText="#{msgs.cpf}#{msgs.dois_pontos}"
						filterBy="#{professor.cpf}" filterMatchMode="contains"
						footerText="#{msgs.contem}">
						<h:outputText value="#{professor.cpf}" styleClass="letra1" />
					</p:column>
					<p:column style="width:150px;text-align:center"
						headerText="#{msgs.cidade}#{msgs.dois_pontos}"
						filterBy="#{professor.fkCidade.descCidade}"
						filterMatchMode="contains" footerText="#{msgs.contem}">
						<h:outputText value="#{professor.fkCidade.descCidade}" />
					</p:column>
					<p:column style="width:150px;text-align:center"
						headerText="#{msgs.telefone_creche}#{msgs.dois_pontos}"
						filterBy="#{professor.fkTelefoneCreche.numero}"
						filterMatchMode="contains" footerText="#{msgs.contem}">
						<h:outputText value="#{professor.fkTelefoneCreche.numero}"
							styleClass="letra1" />
					</p:column>
					<p:column style="width:150px;text-align:center"
						headerText="#{msgs.rg}#{msgs.dois_pontos}"
						filterBy="#{professor.rg}" filterMatchMode="contains"
						footerText="#{msgs.contem}">
						<h:outputText value="#{professor.rg}" />
					</p:column>
					<p:column style="width:50px;text-align:center">
						<p:commandButton image="ui-icon-pencil" title="Alterar"
							update="formCadastroProfessor,modalProfessor"
							oncomplete="modalProfessor.show()" process="@this"
							action="#{professorBean.atualizarDadosProfessor}">
							<f:setPropertyActionListener target="#{professorBean.professor}"
								value="#{professor}" />
						</p:commandButton>
					</p:column>
					<p:column style="width:50px;text-align:center">
						<p:commandButton action="#{professorBean.excluir}"
							image="ui-icon-close" title="Excluir" process="@this"
							update="formConsultaProfessor,painelConsulta">
							<f:setPropertyActionListener target="#{professorBean.professor}"
								value="#{professor}" />
						</p:commandButton>
					</p:column>
				</p:dataTable>
			</p:panel>
		</h:form>
		<p:dialog header="#{msgs.cadastro_professores}"
			widgetVar="modalProfessor" modal="true" height="500" width="800"
			showEffect="highlight">
			<h:form id="formCadastroProfessor" prependId="false">

				<p:fieldset legend="#{msgs.dados_pessoais}">
					<p:ajaxStatus id="ajaxWaitProf"
						style="position:absolute;margin-top:-17px;margin-left:43%;z-index:9;">
						<f:facet name="start">
							<h:graphicImage value="images/aguarde.gif" />
						</f:facet>
						<f:facet name="complete">
							<h:outputText value="" />
						</f:facet>
					</p:ajaxStatus>
					<h:panelGrid columns="3" width="90%">
						<h:outputLabel value="#{msgs.nome}#{msgs.dois_pontos}" />
						<h:outputLabel value="#{msgs.data_nascimento}#{msgs.dois_pontos}"
							style="margin-right:135px" />
						<h:panelGroup />
						<p:inputText id="nome" value="#{professorBean.professor.nome}"
							maxlength="70" size="50" required="true">
							<p:message for="nome" />
						</p:inputText>
						<p:calendar id="dataNasc"
							value="#{professorBean.professor.dataNasc}" locale="pt_Br"
							navigator="true" showButtonPanel="true" required="true">
							<p:message for="dataNasc" />
						</p:calendar>
						<h:panelGroup />
					</h:panelGrid>
					<h:panelGrid columns="3" width="70%">
						<h:outputLabel value="#{msgs.cpf}#{msgs.dois_pontos}" />
						<h:outputLabel value="#{msgs.rg}#{msgs.dois_pontos}" />
						<h:outputLabel value="#{msgs.estado_civil}#{msgs.dois_pontos}" />

						<p:inputText id="cpf" value="#{professorBean.professor.cpf}"
							maxlength="20" required="true">
							<p:message for="cpf" />
						</p:inputText>
						<p:inputText id="rg" value="#{professorBean.professor.rg}"
							maxlength="20" required="true">
							<p:message for="rg" />
						</p:inputText>
						<h:selectOneMenu value="#{professorBean.idEstadoCivil}"
							id="estado_civil">
							<f:selectItem itemLabel="SELECIONE" itemValue="0" />
							<f:selectItems value="#{professorBean.selectItensEstadosCivis}"
								var="estadoCivil" itemLabel="#{estadoCivil.descEstadoCivil}"
								itemValue="#{estadoCivil.idestadoCivil}" />
							<f:validator
								validatorId="br.com.pirralhos.view.validation.ComboValidator" />
							<p:message for="estado_civil" />
						</h:selectOneMenu>
						<h:outputLabel
							value="#{msgs.telefone_residencial}#{msgs.dois_pontos}" />
						<h:outputLabel value="#{msgs.telefone_creche}#{msgs.dois_pontos}" />
						<h:panelGroup />
						<p:inputMask id="telefoneResidencial"
							value="#{professorBean.professor.telefoneResidencial}"
							maxlength="20" mask="(99) 9999-9999" />
						<h:selectOneMenu value="#{professorBean.idTelefoneCreche}"
							id="telefone_creche">
							<f:selectItem itemLabel="SELECIONE" itemValue="0" />
							<f:selectItems
								value="#{professorBean.selectItensTelefonesCreche}"
								var="telefoneCreche" itemLabel="#{telefoneCreche.numero}"
								itemValue="#{telefoneCreche.idtelefoneCreche}" />
							<f:validator
								validatorId="br.com.pirralhos.view.validation.ComboValidator" />
							<p:message for="telefone_creche" />
						</h:selectOneMenu>
						<h:panelGroup />
					</h:panelGrid>
					<h:panelGrid columns="3" width="90%">
						<h:outputLabel value="#{msgs.email}#{msgs.dois_pontos}" />
						<h:outputLabel value="#{msgs.sexo}#{msgs.dois_pontos}"
							style="margin-right:217px" />
						<h:panelGroup />
						<p:inputText id="email" value="#{professorBean.professor.email}"
							maxlength="75" size="50">
							<f:validator
								validatorId="br.com.pirralhos.view.validation.EmailValidator" />
						</p:inputText>
						<h:selectOneMenu value="#{professorBean.idSexo}" id="sexo">
							<f:selectItem itemLabel="SELECIONE" itemValue="0" />
							<f:selectItems value="#{sexoBean.listaSexos}" var="sexo"
								itemLabel="#{sexo.descSexo}" itemValue="#{sexo.idsexo}" />
							<f:validator
								validatorId="br.com.pirralhos.view.validation.ComboValidator" />
							<p:message for="sexo" />
						</h:selectOneMenu>
						<h:panelGroup />
					</h:panelGrid>
				</p:fieldset>
				<p:fieldset legend="#{msgs.dados_endereco}">
					<h:panelGrid columns="3" width="90%">
						<h:outputLabel value="#{msgs.endereco}#{msgs.dois_pontos}" />
						<h:outputLabel value="#{msgs.numero}#{msgs.dois_pontos}"
							style="margin-right:200px" />
						<h:panelGroup />
						<p:inputText id="endereco"
							value="#{professorBean.professor.endereco}" maxlength="75"
							size="50" required="true">
							<p:message for="endereco" />
						</p:inputText>
						<p:inputText id="numero" value="#{professorBean.professor.numero}"
							maxlength="10" required="true">
							<p:message for="numero" />
						</p:inputText>
						<h:panelGroup />
					</h:panelGrid>
					<h:panelGrid columns="3" width="70%">
						<h:outputLabel value="#{msgs.complemento}#{msgs.dois_pontos}" />
						<h:outputLabel value="#{msgs.cep}#{msgs.dois_pontos}" />
						<h:outputLabel value="#{msgs.estado}#{msgs.dois_pontos}" />
						<p:inputText id="complemento"
							value="#{professorBean.professor.complemento}" maxlength="20">
						</p:inputText>
						<p:inputText id="cep" value="#{professorBean.professor.cep}"
							maxlength="20" required="true">
							<p:message for="cep" />
						</p:inputText>
						<h:selectOneMenu value="#{professorBean.idEstado}" id="estado">
							<f:selectItem itemLabel="SELECIONE" itemValue="0" />
							<f:selectItems value="#{professorBean.selectItensEstados}" />
							<p:ajax listener="#{professorBean.popularCidade}"
								update="cidades" process="@this" />
							<f:validator
								validatorId="br.com.pirralhos.view.validation.ComboValidator" />
							<p:message for="estado" />
						</h:selectOneMenu>
						<h:outputLabel value="#{msgs.cidade}#{msgs.dois_pontos}" />
						<h:outputLabel value="#{msgs.bairro}#{msgs.dois_pontos}" />
						<h:panelGroup />
						<h:selectOneMenu value="#{professorBean.idCidade}" id="cidades"
							disabled="#{empty professorBean.selectItensCidades}">
							<f:selectItem itemLabel="SELECIONE" itemValue="0" />
							<f:selectItems value="#{professorBean.selectItensCidades}" />
							<f:validator
								validatorId="br.com.pirralhos.view.validation.ComboValidator" />
							<p:message for="cidades" />
						</h:selectOneMenu>
						<p:inputText id="bairro" value="#{professorBean.professor.bairro}"
							maxlength="50" required="true">
							<p:message for="bairro" />
						</p:inputText>
					</h:panelGrid>
				</p:fieldset>
				<p:fieldset legend="#{msgs.dados_contrato}">
					<h:panelGrid columns="2" width="70%">
						<h:outputLabel value="#{msgs.data_admissao}#{msgs.dois_pontos}" />
						<h:outputLabel value="#{msgs.data_saida}#{msgs.dois_pontos}" />
						<p:calendar id="dataAdmissao"
							value="#{professorBean.professor.dataAdmissao}" locale="pt_Br"
							navigator="true" showButtonPanel="true" required="true">
							<p:message for="dataAdmissao" />
						</p:calendar>
						<p:calendar value="#{professorBean.professor.dataSaida}"
							locale="pt_Br" navigator="true" showButtonPanel="true" />
					</h:panelGrid>
				</p:fieldset>
				<p:fieldset legend="#{msgs.dados_usuario}">
					<h:panelGrid columns="1" width="70%">
						<h:outputLabel value="#{msgs.login}#{msgs.dois_pontos}" />
						<p:inputText id="login" value="#{professorBean.login}"
							maxlength="20" required="true">
							<p:message for="login" />
						</p:inputText>
					</h:panelGrid>
					<h:inputHidden id="hiddenAlterouProfessor"
						value="#{professorBean.alterou}" />

					<h:panelGrid styleClass="painelBotoes" columns="3">
						<p:commandButton value="#{msgs.botao_confirmar}"
							action="#{professorBean.atualiza}"
							oncomplete="if(document.getElementById('hiddenAlterouProfessor').value=='true'){modalProfessor.hide();}"
							update="formCadastroProfessor,formConsultaProfessor" />
					</h:panelGrid>
				</p:fieldset>

			</h:form>
		</p:dialog>
	</ui:define>
</ui:composition>
